<%@ include file="/Pages/Jsp/Common/header.jsp"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<script>
$(document).ready(function(){ 
	//$("#NoticeField").fadeOut(3000);
    if($(".requiredNotice").html()== ""){
        $(".requiredNotice").hide(); 
     }
});
</script>
<div style="width:960px; margin-left:auto;margin-right:auto;">
<div class="span-22 append-10 last">
      <form name="frmCreateRole" action="<%=request.getContextPath()%>/roleMgt/createRole.do?action=create" method="post">
      	<div class="requiredNotice error">
        </div>
      	<div id="NoticeField" class="span-10 last append-14">	
		<logic:present name="Success">
			<div class="notice">
				<b>${Success}</b>
			</div>
		</logic:present>
		<logic:present name="Failed">
			<div class="error">
				<b>${Failed}</b>
			</div>
		</logic:present>
		</div>	
      	<div>
      	  <h3>Create Role</h3>
      	  <hr/>
        </div>
    	<hr class="space prepend">

          <p>
            <label class="span-3 append-1 align-left "><span class="errtxt">*</span> Role Name:</label>
            <input id="Role" name="role_name" class="span-4 redlight" type="text" onBlur="checkRoleNameCreateRole();">
            <SPAN id="role_nameError" style="display: none" class="errorText">Please fill in the mandatory field "Role Name"!</SPAN>
            <SPAN id="role_nameExistError" style="display: none" class="errorText">The "Role Name" already exist, please fill in again!</SPAN>
          </p>
          <p>
            <label class="span-3 append-1 align-left "><span class="errtxt">*</span> Active:</label>
            <select id="RoleActive" name="roleActive" class="span-4">
            	<option>Yes</option>
            	<option>No</option>
            </select>
          </p>
          <p>
            <label class="span-4 align-left "><span class="errtxt">*</span> Permissions:</label>  
          </p>
		  <br></br>
          	<table id="Permission" class="blueTable span-22">
          	<tr>
          	<th width="20%">Category</th>
          	<th width="80%">Functionalities</th>
          	</tr>
			<logic:iterate id="FunctionalityList_Cat" name="createRoleForm" property="categoryList"
				type="String">
          	<tr>
          		<td><bean:write name="FunctionalityList_Cat" /></td>
          		<td>
          			<logic:iterate id="FunctionalityList_Fun" name="createRoleForm" property="functionalityList"
						type="com.capgemini.fs.app.ekms.model.Functionality">
						<logic:equal   name= "FunctionalityList_Fun"   property= "category"   value= "${FunctionalityList_Cat}"> 
						<span>
          				<input type="checkbox" name="functionCheckBox" title="functionRole" value="${FunctionalityList_Fun.functionalityCode}">
          				<bean:write name="FunctionalityList_Fun" property="functionalityName" />
          				</span>
          				</logic:equal> 
          			</logic:iterate>
          		</td>
          	</tr>
          	</logic:iterate>
          	</table>
            <SPAN id="permissionError" style="display: none" class="errorText">Please assign at least one permission to a role.</SPAN>
          <div id="button">
            <input value="Create" type="button" onClick="alertRoleConfirm('create')">&nbsp;
            <input value="Reset" type="reset" onClick="resetForm()">&nbsp;
            <input value="Back" type="button" onClick="window.location.href='<%=request.getContextPath()%>/login.do'">
          <hr class="space"/>
          </div>
          <input style="display: none" id="hiddenCreateRole" name="createRole">
			<div id="popDiv" class="rolePopupDiv span-18 noDisplay" >
				<div class="popTitle span-16">Create Role Confirmation</div> 
				<div class="handLink span-1 closeX last" onClick="resetRoleDialog()">X</div>
				<hr></hr>
			    <div id="roleConfirm">
			    "<span id="hiddenRoleName"></span>"&nbsp;will be created with following permissions.
			    <br>
			    <span>Active: </span><span id="hiddenActive"></span>
			    <br>
			    <span>Permissions: </span>
			    <table id="hiddenPermission" class="noDisplay"></table>
			    <div id="button">
			    <input type="Submit" onClick="" value="Create"></input>&nbsp;
			    <input type="Button" onClick="resetRoleDialog()" value="Back"></input>
			    </div>
			    </div>
			</div>
			<div id="loadingbg" class="bg noDisplay">
			</div>
      </form>
    </div>
</div>